
// 创建闭包
let Singleton = (function() {
    let instance = null;
    return function(name) {
        if(!instance) {
            this.name = name;
            instance = this;
        }
        return instance;
    }
})()

const p = new Singleton('liuyu');
const p1 = new Singleton('liudada');

console.log(p);
console.log(p1);